﻿@model IEnumerable<Microsoft.Samples.WindowsPhoneCloud.Web.Models.UserPermissionsModel>
@{
    ViewBag.Title = "Manage User Permissions";
}
<h2>
    Manage User Permissions</h2>
<p>
    Select what content type can access each user.
</p>
<table>
    <tr>
        <th class="left-aligned">
            User
        </th>
        <th>
            Tables
        </th>
        <th>
            Blobs
        </th>
        <th>
            Queues
        </th>
        <th>
            SQL
        </th>
    </tr>
    @{ var i = 0; }
    @foreach (var item in this.Model)
    {
        i++;
            
        <tr class="d@( (i % 2))">
            <td class="left-aligned">
                @( item.UserName)
            </td>
            <td>
            @{ var tablesChecked = item.TablesUsage ? "checked=\"checked\"" : string.Empty; }
                <input id="Tables_@( item.UserId)" onclick="EnableContent('@( item.UserId)', actionUrl)"
                    type="checkbox" @this.Html.Raw(tablesChecked)  />
            </td>
            <td>
            @{ var blobsChecked = item.BlobsUsage ? "checked=\"checked\"" : string.Empty; }
                <input id="Blobs_@( item.UserId)" onclick="EnableContent('@( item.UserId)', actionUrl)"
                    type="checkbox" @this.Html.Raw(blobsChecked) />
            </td>
            <td>
            @{ var queuesChecked = item.QueuesUsage ? "checked=\"checked\"" : string.Empty; }
                <input id="Queues_@( item.UserId)" onclick="EnableContent('@( item.UserId)', actionUrl)"
                    type="checkbox" @this.Html.Raw(queuesChecked) />
            </td>
            <td>
            @{ var sqlChecked = item.SqlUsage ? "checked=\"checked\"" : string.Empty; }
                <input id="Sql_@( item.UserId)" onclick="EnableContent('@( item.UserId)', actionUrl)"
                    type="checkbox" @this.Html.Raw(sqlChecked) />
            </td>
        </tr>
    }
</table>
<script type="text/javascript">
//<![CDATA[
    var actionUrl = '@this.Html.Raw(this.Url.Action("SetUserPermissions", new { userId = "_user_", useTables = "_useTables_", useBlobs = "_useBlobs_", useQueues = "_useQueues_", useSql = "_useSql_" }))';
//]]>
</script>
